<?php

define('KEY','Lv3ro5gmnT1svLFG');
define('IV','TL0Kqiqydyb9FDGL');

header("Access-Control-Allow-Origin: *");
$endata =   $_POST['post_data']['enData'];

$dedata = decrypt($endata,KEY,IV);
$dataArr = json_decode($dedata,true);

exit( json_encode(['status'=>200,'msg'=>'ok','data'=>$dataArr]));



/**
 * 加密字符串
 * @param string $data 字符串
 * @param string $key 加密key
 * @param string $iv 加密向量
 * @return string
 */
function encrypt($data, $key, $iv)
{
    $encrypted = openssl_encrypt($data, "AES-128-CBC", $key, true, $iv);
    return base64_encode($encrypted);
}

/**
 * 解密字符串
 * @param string $data 字符串
 * @param string $key 加密key
 * @param string $iv 加密向量
 * @return object
 */
function decrypt($data, $key, $iv)
{
    $decrypted = openssl_decrypt(base64_decode($data), 'AES-128-CBC', $key, true, $iv);
    $json_str = rtrim($decrypted, "\0");
    return $json_str;
//    return json_decode($json_str);
}